<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta content="text/html;charset=UTF-8"/>
    <title>登录页面</title>
    <link rel="stylesheet" th:href="@{assert/bootstrap-3.3.7-dist/css/bootstrap.min.css}"/>

    <script th:src="@{assert/jquery/jquery.min.js}"></script>
    <script th:src="@{assert/jquery/jquery.form.js}"></script>
    <script th:src="@{assert/common/extends.js}"></script>

</head>
<body>

<nav class="navbar navbar-inverse navbar-fixed-top">
    <div class="container">
        <div class="navbar-header">
            <a class="navbar-brand" href="#">Spring Security演示</a>
        </div>
        <div id="navbar" class="collapse navbar-collapse">
            <ul class="nav navbar-nav">
                <li><a th:href="@{/logout}"> 注销 </a></li>

            </ul>
        </div>
        <!--/.nav-collapse -->
    </div>
</nav>
<div class="container">

    <div class="starter-template">

        <h2>使用账号密码登录</h2>
        <form name="form" th:action="@{/login}" action="/login" method="POST">
            <!-- 3 -->
            <div class="form-group">
                <label for="username">账号</label> <input type="text"
                                                        class="form-control" name="username" value="hhm"
                                                        placeholder="账号"/>
            </div>
            <div class="form-group">
                <label for="password">密码</label> <input type="password"
                                                        class="form-control" name="password" placeholder="密码"
                                                        value="1d5cd27e237ff81c8c7601ba479c33f2"/>
            </div>
            <input type="button" id="login" value="登录"
                   class="btn btn-primary"/>
        </form>
    </div>


    <div class="row-fluid">
        <div class="span12">
            <table class="table">
                <thead>
                <tr>
                    <th>
                        说明
                    </th>
                    <th>
                        操作
                    </th>

                </tr>
                </thead>
                <tbody>
                <tr>
                    <td>
                        /user/list
                    </td>
                    <td>
                        <button type="button" class="btn btn-default" onclick="PageJS.test(1)">请求</button>
                    </td>

                </tr>


                <tr>
                    <td>
                        /user/1
                    </td>
                    <td>
                        <button type="button" class="btn btn-default" onclick="PageJS.test(2)">请求</button>
                    </td>

                </tr>
                <tr>
                    <td>
                        /user/add
                    </td>
                    <td>
                        <button type="button" class="btn btn-default" onclick="PageJS.test(3)">请求</button>
                    </td>

                </tr>
                </tbody>
            </table>
        </div>
    </div>

</div>


<script>
    PageJS = {

        init: function () {
            $("#login").click(function () {

                XAJA($("form")).success(function (msg) {

                    alert(msg);

                }).form();

            });
        },


        test: function (flag) {

            var url;
            if (flag == 1) {
                url = "/user/list";
                XAJA(url).get();

            } else if (flag == 2) {
                url = "/user/2";
                XAJA(url).get();

            } else if (flag == 3) {
                url = "/user/add";
                XAJA(url).post();

            }


        }

    }


    $(function () {

        PageJS.init();
    });


</script>

</body>
</html>